from django.contrib import admin
from fruit import models
# Register your models here.
#用户表
class UserAdmin(admin.ModelAdmin):
    #列表显示字段
    list_display = ("user_name","status","phone")
    #搜索字段
    search_fields = ['user_name']
    #设置过滤字段，过滤后会出现在右侧
    list_filter = ["user_name","phone"]

#注册用户表
admin.site.register(models.User,UserAdmin)

#商品表
class GoodsAdmin(admin.ModelAdmin):
    #列表显示字段
    list_display = ["good_name","imr_url","intro"]
    search_fields = ['good_name']
    list_filter = ["good_name"]

admin.site.register(models.Goods,GoodsAdmin)
#商品类型表
class TypeAdmin(admin.ModelAdmin):
    list_display = ['type_name']

admin.site.register(models.Type,TypeAdmin)

#收货地址
class AddressAdmin(admin.ModelAdmin):
    #列表显示字段
    list_display = ["user_name","address","phone"]
    search_fields = ['user_naem']
    list_filter = ["user_name"]

admin.site.register(models.Address,AddressAdmin)

#订单列表
class OrderAdmin(admin.ModelAdmin):
    list_display = ["order_no","user_name","phone","address","total_price"]
    search_fields = ['user_name','phone']
    list_filter = ["user_name","phone"]

#注册订单表
admin.site.register(models.Order,OrderAdmin)

admin.site.site_header = '天天生鲜后台管理'

